Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rule to detect private usages in imports from local modules #187

Merged
merged 9 commits into from
Mar 24, 2024

Conversation

DetachHead
Copy link
Owner

fixes #104

This comment has been minimized.

This comment has been minimized.

@DetachHead DetachHead changed the title add rule to detect private non-py.typed import usages add rule to detect private non-py.typed import usages Mar 24, 2024

This comment has been minimized.

This comment has been minimized.

@DetachHead DetachHead changed the title add rule to detect private non-py.typed import usages add rule to detect private usages in imports from local modules Mar 24, 2024

This comment has been minimized.

Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

PyWinCtl (https://github.com/Kalmat/PyWinCtl)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:23:21 - error: "displaysCount" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:23:36 - error: "getDisplays" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:23:49 - error: "getDisplaysInfo" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:23:66 - error: "getRoots" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:23:76 - error: "getRootsInfo" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:24:21 - error: "defaultDisplay" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:24:37 - error: "defaultScreen" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:24:52 - error: "defaultRoot" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:24:65 - error: "defaultEwmhRoot" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:25:21 - error: "getDisplayFromRoot" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:25:41 - error: "getScreenFromRoot" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:26:21 - error: "getDisplayFromWindow" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:26:43 - error: "getScreenFromWindow" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:26:64 - error: "getRootFromWindow" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:27:21 - error: "getProperty" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:27:34 - error: "getPropertyValue" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:27:52 - error: "changeProperty" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:27:68 - error: "sendMessage" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:28:21 - error: "EwmhRoot" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/__init__.py:28:31 - error: "EwmhWindow" is not exported from module "._main"
+     Import from "ewmhlib._ewmhlib" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/_ewmhlib.py:25:28 - error: "Root" is not exported from module "ewmhlib.Props"
+     Import from "ewmhlib.Props._props" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/_ewmhlib.py:25:34 - error: "DesktopLayout" is not exported from module "ewmhlib.Props"
+     Import from "ewmhlib.Props._props" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/_ewmhlib.py:25:49 - error: "Window" is not exported from module "ewmhlib.Props"
+     Import from "ewmhlib.Props._props" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/_ewmhlib.py:25:57 - error: "WindowType" is not exported from module "ewmhlib.Props"
+     Import from "ewmhlib.Props._props" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/_ewmhlib.py:25:69 - error: "State" is not exported from module "ewmhlib.Props"
+     Import from "ewmhlib.Props._props" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/_ewmhlib.py:25:76 - error: "StateAction" is not exported from module "ewmhlib.Props"
+     Import from "ewmhlib.Props._props" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/_ewmhlib.py:26:28 - error: "MoveResize" is not exported from module "ewmhlib.Props"
+     Import from "ewmhlib.Props._props" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/_ewmhlib.py:26:40 - error: "DataFormat" is not exported from module "ewmhlib.Props"
+     Import from "ewmhlib.Props._props" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/_ewmhlib.py:26:52 - error: "Mode" is not exported from module "ewmhlib.Props"
+     Import from "ewmhlib.Props._props" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/_ewmhlib.py:26:58 - error: "HintAction" is not exported from module "ewmhlib.Props"
+     Import from "ewmhlib.Props._props" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/_ewmhlib.py:27:29 - error: "DisplaysInfo" is not exported from module "ewmhlib.Structs"
+     Import from "ewmhlib.Structs._structs" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/_ewmhlib.py:27:43 - error: "ScreensInfo" is not exported from module "ewmhlib.Structs"
+     Import from "ewmhlib.Structs._structs" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/_ewmhlib.py:27:56 - error: "WmHints" is not exported from module "ewmhlib.Structs"
+     Import from "ewmhlib.Structs._structs" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/_ewmhlib.py:27:65 - error: "Aspect" is not exported from module "ewmhlib.Structs"
+     Import from "ewmhlib.Structs._structs" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/ewmhlib/_ewmhlib.py:27:73 - error: "WmNormalHints" is not exported from module "ewmhlib.Structs"
+     Import from "ewmhlib.Structs._structs" instead (reportPrivateLocalImportUsage)
+ /tmp/mypy_primer/projects/PyWinCtl/src/pywinctl/__init__.py
+   /tmp/mypy_primer/projects/PyWinCtl/src/pywinctl/__init__.py:27:25 - error: "Window" is not exported from module "._main"
+     Import from "pywinctl._pywinctl_linux" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/pywinctl/__init__.py:27:33 - error: "checkPermissions" is not exported from module "._main"
+     Import from "pywinctl._pywinctl_linux" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/pywinctl/__init__.py:27:51 - error: "getActiveWindow" is not exported from module "._main"
+     Import from "pywinctl._pywinctl_linux" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/pywinctl/__init__.py:28:21 - error: "getActiveWindowTitle" is not exported from module "._main"
+     Import from "pywinctl._pywinctl_linux" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/pywinctl/__init__.py:28:43 - error: "getAllAppsNames" is not exported from module "._main"
+     Import from "pywinctl._pywinctl_linux" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/pywinctl/__init__.py:28:60 - error: "getAllAppsWindowsTitles" is not exported from module "._main"
+     Import from "pywinctl._pywinctl_linux" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/pywinctl/__init__.py:29:21 - error: "getAllTitles" is not exported from module "._main"
+     Import from "pywinctl._pywinctl_linux" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/pywinctl/__init__.py:29:35 - error: "getAllWindows" is not exported from module "._main"
+     Import from "pywinctl._pywinctl_linux" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/pywinctl/__init__.py:29:50 - error: "getAppsWithName" is not exported from module "._main"
+     Import from "pywinctl._pywinctl_linux" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/pywinctl/__init__.py:29:67 - error: "getWindowsWithTitle" is not exported from module "._main"
+     Import from "pywinctl._pywinctl_linux" instead (reportPrivateLocalImportUsage)
+   /tmp/mypy_primer/projects/PyWinCtl/src/pywinctl/__init__.py:30:21 - error: "getTopWindowAt" is not exported from module "._main"
+     Import from "pywinctl._pywinctl_linux" instead (reportPrivateLocalImportUsage)

... (truncated 35 lines) ...

@DetachHead DetachHead merged commit e5f24ec into main Mar 24, 2024
11 checks passed
@DetachHead DetachHead deleted the private-import branch March 24, 2024 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

reportPrivateImportUsage should complain about any implicit import, not just py.typed ones
1 participant